package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Order;
import com.example.demo.entity.Order2;
import com.example.demo.entity.Commdity;
import com.example.demo.entity.Shop;
import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface OrderMapper extends BaseMapper<Order> {
    @Select("SELECT id,price,name,orderid,address,phone,state FROM Order1")
    List<Order> findAll();

    @Select("SELECT id,price,orderid,name,address,phone,state FROM Order1 where state=#{state}")
    List<Order> findBy_state(int state);

    @Select("SELECT id,price,name,orderid,address,phone,state FROM Order1 where id=#{id}")
    List<Order> findBy_id(int id);

    //取消订单
    @Select("UPDATE order1,order2 SET order1.state=-1,order2.state=-1 where order2.relaid=order1.orderid and order1.orderid=#{orderid}")
    Boolean modify(int orderid);

    //支付订单
    @Select("UPDATE order1,order2 SET order1.state=1,order2.state=1 where order2.relaid=order1.orderid and order1.orderid=#{orderid}")
    Boolean modify_state1(int orderid);

    //确认发货
    @Select("UPDATE order1,order2 SET order1.state=3,order2.state=3 where order2.relaid=order1.orderid and order1.orderid=#{orderid}")
    Boolean modify_state3(int orderid);

    //确认收货
    @Select("UPDATE order1,order2 SET order1.state=4,order2.state=4 where order2.relaid=order1.orderid and order1.orderid=#{orderid}")
    Boolean modify_state4(int orderid);

    //申请退单
    @Select("UPDATE order1,order2 SET order1.state=-2,order2.state=-2 where order2.relaid=order1.orderid and order1.orderid=#{orderid}")
    Boolean modify_state2(int orderid);

    //同意退货
    @Select("UPDATE order1,order2 SET order1.state=-3,order2.state=-3 where order2.relaid=order1.orderid and order1.orderid=#{orderid}")
    Boolean modify_state5(int orderid);
}
